﻿using OdeToFoo.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace OdeToFoo.Controllers
{


    public class ReviewController : Controller
    {

        ////http://localhost:64835/review/bestreview will fail since this is child action only
        ////ChildActionOnly cannot be called directly
        //[ChildActionOnly]
        //public ActionResult BestReview()
        //{
        //    var bestReview = from r in _reviews
        //                     orderby r.Rating descending
        //                     select r;
          

        //    return PartialView("_Review", bestReview.First());
        //}











        ////
        //// GET: /Review/

        //public ActionResult Index()
        //{
        //    var model =
        //        from r in _reviews
        //        orderby r.Rating
        //        select r;

        //    return View(model);
        //}

        ////
        //// GET: /Review/Details/5

        //public ActionResult Details(int id)
        //{
        //    return View();
        //}

        ////
        //// GET: /Review/Create

        //public ActionResult Create()
        //{
        //    return View();
        //}

        ////
        //// POST: /Review/Create

        //[HttpPost]
        //public ActionResult Create(FormCollection collection)
        //{
        //    try
        //    {
        //        // TODO: Add insert logic here

        //        return RedirectToAction("Index");
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}

        ////
        //// GET: /Review/Edit/5

        //public ActionResult Edit(int id)
        //{
        //    var review = _reviews.Single(r => r.Id == id);
        //    return View(review);
        //}

        ////
        //// POST: /Review/Edit/5

        //[HttpPost]
        //public ActionResult Edit(int id, FormCollection collection)
        //{
        //    Console.WriteLine("Hi");
        //    var review = _reviews.Single(r => r.Id == id);
        //    if (TryUpdateModel(review))
        //    {   
        //        return RedirectToAction("Index");
        //    }
        //    return View(review);
        //}

        ////
        //// GET: /Review/Delete/5

        //public ActionResult Delete(int id)
        //{
        //    return View();
        //}

        ////
        //// POST: /Review/Delete/5

        //[HttpPost]
        //public ActionResult Delete(int id, FormCollection collection)
        //{
        //    try
        //    {
        //        // TODO: Add delete logic here

        //        return RedirectToAction("Index");
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}




        //////These items are suppose to come from a database, but we will use it for now for testing purpose
        //static List<RestaurantReview> _reviews = new List<RestaurantReview>
        //{
        //    new RestaurantReview{
        //        Id = 1,
        //        Rating = 5,
        //    },
        //     new RestaurantReview{
        //        Id = 2,
        //        Rating = 2,
        //    },
        //     new RestaurantReview{
        //        Id = 3,
        //        Rating = 9,
        //    }

        //};
    }
}
